/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package action.Room;

import Database.RoomDAO;
import Models.*;
import java.util.*;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;

/**
 *
 * @author trang_000
 */
public class RoomAction extends ActionSupport{
    List<Room> roomsResultList;
    RoomDAO roomDAO = new RoomDAO();
    int floor;

    public List<Room> getRoomsResultList() {
        return roomsResultList;
    }

    public void setRoomsResultList(List<Room> roomsResultList) {
        this.roomsResultList = roomsResultList;
    }

    public int getFloor() {
        return floor;
    }

    public void setFloor(int floor) {
        this.floor = floor;
    }
    
    @Override
    @Action(value = "Etape/*", results = {
        @Result(name = "success", location = "/Room/RoomHomePage.jsp")},
            params = {"floor", "{1}"})
    public String execute() throws Exception {
        roomsResultList = roomDAO.getRoomListByFloor(floor);
        if (roomsResultList.size()== 0)
            addActionMessage("No Items Found");
        return SUCCESS;
    }    
    
    @Action(value="Common-Infos/Chambre-et-lit", results = {
        @Result(name="success", location="/Room/RoomHomePage.jsp")
    })
    public String romehome() throws Exception{
        return SUCCESS;
    }
}
